<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>删除会员信息画面</title>
    <!-- 引入 Bootstrap CSS -->
    <link href="../static/css/bootstrap.min.css" rel="stylesheet">
    <!-- 引入 jQuery -->
    <script src="../static/js/jquery-3.6.4.min.js"></script>
    <link href="/css/delete.css" rel="stylesheet">
</head>
<body>
<div class="container my-5">


    <!-- 表单 -->
    <form class="card p-4 shadow-sm" id="memberForm">
        <h1 class="text-center mb-4">删除会员信息画面</h1>
        <div class="mb-3 row">
            <label for="memberId" class="col-sm-2 col-form-label">编号</label>
            <div class="col-sm-6">
                <input type="text" class="form-control" id="memberId" value="">
                <div class="text-danger mt-1" id="idError" style="display: none;">* 会员编号必须为4位数字！</div>
            </div>
        </div>
        <div class="text-center mt-4">
            <button type="button" class="btn btn-primary" id="submitBtn">删除</button>
            <a href="select.html" class="btn btn-link">首页</a>
        </div>
    </form>
</div>

<!-- 引入 Bootstrap JS -->
<script src="../static/js/bootstrap.bundle.min.js"></script>

<script>
    function goupdateok(){
        const id = $('#memberId').val();

        // 将数据存储到localStorage
        localStorage.setItem('memberId', id);
        window.location.href = "deletok.html";
    }

    $('#submitBtn').click(function () {
        let isValid = true;

        // 校验会员编号
        const id = $('#memberId').val();
        if (!/^\d{4}$/.test(id)) {
            $('#idError').show();
            isValid = false;
        } else {
            $('#idError').hide();
        }

        // 如果校验通过，提交表单
        if (isValid) {
            goupdateok();
            // alert('会员信息已添加成功！');
            // 可通过 Ajax 提交到服务器
        }
    });
</script>
</body>
</html>
